var _year = {
	years: [],
	currentYear: 0
};
var _STAT_TITLE = "";
var _checkStatEnum = {};
var _columnFormatter = {};

function getyear() {
	vw_common.customAjax({
		url: VW_INTERFACE.WEBSERVICE.TableManage('GetTableData'),
		type: "GET",
		async: false,
		dataType: "json",
		data: {
			table: "TB_BIZ_YEAR"
		}
	}, function(e) {
		var f_year, f_curYear;
		$.each(e.column, function(k, val) {
			if(val == "F_YEAR") {
				f_year = k;
			}
			if(val == "F_CURRENTYEAR") {
				f_curYear = k;
			}
		});

		$.each(e.data, function(k, val) {
			_year.years.push(val[f_year]);
			if(val[f_curYear] == "1") {
				_year.currentYear = val[f_year];
				$('#currentYear').text(_year.currentYear);
			}
		});
	});
}

function getCheckStat(text) {
	_STAT_TITLE = text;
	_columnFormatter[_STAT_TITLE] = function(value, row, index) {
		if(row[_STAT_TITLE]) {
			var item = _checkStatEnum[row[_STAT_TITLE]];
			return '<span class="label label-' + item.style + '">' + item.text + '</span>';
		}
	}

	vw_common.customAjax({
		url: VW_INTERFACE.WEBSERVICE.TableManage('GetTableData'),
		type: "GET",
		dataType: "json",
		data: {
			table: "TB_BIZ_SURVEY_STATUS"
		}
	}, function(e) {
		var f_id, f_text, f_style;
		$.each(e.column, function(k, val) {
			if(val == "F_ID") {
				f_id = k;
			}
			if(val == "F_NAME") {
				f_text = k;
			}
			if(val == "F_STYLE") {
				f_style = k;
			}
		});

		$.each(e.data, function(k, val) {
			_checkStatEnum[val[f_text]] = {
				id: val[f_id],
				text: val[f_text],
				style: val[f_style]
			};
		});
	});
}